package com.sky.mapper;


import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 通过opneid 查询用户信息
     * @param openid
     * @return
     */
    @Select("SELECT *FROM user where openid = #{openid} ")
    User getByOpenid(String openid);

    /**
     * 插入用户信息
     * @param user
     * @return
     */
    int insertUser(User user);

    /**
     * 通过用户id查询
     * @param userId
     * @return
     */
    @Select("SELECT *FROM user where id = #{userId}")
    User selectById(Long userId);

    /**
     * 根据日期查询用户数量
     * @param beginTime
     * @param endTime
     * @return
     */
    Integer countByCreateTime(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 根据日期查询用户
     * @param beginTime
     * @param endTime
     * @return
     */
    List<User> selectByCreateTime(LocalDateTime beginTime, LocalDateTime endTime);
}
